package com.xzc.kafka.action.consumer._3CP;

import java.util.ArrayList;
import java.util.List;

public class ConsumerGroup {

    private List<ConsumerRunable> consumers;

    public ConsumerGroup(int consumerNum, String groupId, String topic, String brokerList) {
        consumers = new ArrayList<>(consumerNum);
        for (int i = 0; i < consumerNum; i++) {
            ConsumerRunable consumerRunable = new ConsumerRunable(brokerList, groupId, topic);
            consumers.add(consumerRunable);
        }
    }

    public void execute() {
        for (ConsumerRunable task : consumers) {
            new Thread(task).start();
        }
    }
}
